//
//  ZJTimeSelectView.m
//  ShangHaiHuDongApp
//
//  Created by ZJ on 2017/6/22.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "ZJTimeSelectView.h"

@interface ZJTimeSelectView ()

/** button */
@property (nonatomic, strong) UIButton *button;
@end

@implementation ZJTimeSelectView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
       
        self.layer.cornerRadius = 4 * [UIScreen zj_screenWScale];
        self.layer.borderWidth = 1;
        self.layer.borderColor = [UIColor zj_colorWithHexString:@"ebebeb"].CGColor;
        [self addSubview:self.time];
        [self addSubview:self.button];
        
        UITapGestureRecognizer *tapGest = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGest)];
        [self addGestureRecognizer:tapGest];
    }
    return self;
}


#pragma mark - 点击事件
- (void)tapGest{
    [self action_button:nil];
}

- (void)action_button:(UIButton *)button{
    if (self.delegate) {
        [self.delegate ZJTimeSelectViewDelegate_showTimeClick:self];
    }
}

#pragma mark - Setter


#pragma mark - Getters
- (UITextField *)time{
    if (_time == nil){
        _time = [[UITextField alloc]initWithFrame:CGRectMake(8 * [UIScreen zj_screenWScale], 0, self.width - (44 + 8) * [UIScreen zj_screenHScale], 44 * [UIScreen zj_screenHScale])];
        _time.textColor = [UIColor textBlackColor];
        _time.font = [UIFont titleTextFont];
        _time.userInteractionEnabled = NO;
    }
    return _time;
}

- (UIButton *)button{
    if (_button == nil){
        _button = [[UIButton alloc]initWithFrame:CGRectMake(self.width - self.time.height, 0, self.time.height, self.time.height)];
        [_button setImage:[UIImage imageNamed:@"icon_calendar"] forState:UIControlStateNormal];
        [_button addTarget:self action:@selector(action_button:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _button;
}

@end
